import requests
import json
import sys

# 简化版测试，尝试更基础的健康检查和API信息获取
BASE_URL = "http://localhost:8001/api/v1"

print("测试健康检查接口...")
try:
    health_check = requests.get("http://localhost:8001/health")
    print(f"健康检查响应: {health_check.status_code}")
    print(f"健康检查内容: {health_check.text}")
except Exception as e:
    print(f"健康检查失败: {e}")
    sys.exit(1)

print("\n测试TTS信息接口...")
try:
    tts_info = requests.get(f"{BASE_URL}/tts/info")
    print(f"TTS信息响应: {tts_info.status_code}")
    if tts_info.status_code == 200:
        info = tts_info.json()
        print(f"TTS信息: {json.dumps(info, indent=2, ensure_ascii=False)}")
except Exception as e:
    print(f"获取TTS信息失败: {e}")

print("\n测试TTS可用语音列表...")
try:
    voices = requests.get(f"{BASE_URL}/tts/voices")
    print(f"语音列表响应: {voices.status_code}")
    if voices.status_code == 200:
        voice_list = voices.json()
        print(f"找到 {len(voice_list)} 个可用语音")
        for i, voice in enumerate(voice_list):
            print(f"  {i+1}. {voice['name']} ({voice['language']})")
except Exception as e:
    print(f"获取语音列表失败: {e}")

print("\n测试完成！")
